package com.lwx.redis;

import java.util.Random;

public class RedisMain {
    public static void main(String[] args) {
        //addString();
        //addHash();
        randomGet();
        randomhget();
    }
    
    private static void randomGet(){
        long start = System.currentTimeMillis();
            for(int i = 0; i < 10000; i++){
                RedisManage.get("user:" + String.valueOf(new Random().nextInt(999999)));
            }
        System.err.println("randomGet: " + (System.currentTimeMillis() - start));
    }
    
    private static void randomhget(){
        long start = System.currentTimeMillis();
        for(int i = 0; i < 10000; i++){
            RedisManage.hget("user", String.valueOf(new Random().nextInt(999999)));
        }
        System.err.println("randomhget: " + (System.currentTimeMillis() - start));
    }
    
    private static void addString(){
        long start = System.currentTimeMillis();
        for(int i = 1; i <= 1000000; i++){
            RedisManage.set("user:" + String.valueOf(i), String.valueOf(i));
        }
        System.err.println("addString: " + (System.currentTimeMillis() - start));
    }
    
    private static void addHash(){
        long start = System.currentTimeMillis();
        for(int i = 1; i <= 1000000; i++){
            RedisManage.hset("user", String.valueOf(i), String.valueOf(i));
        }
        System.err.println("addHash: " + (System.currentTimeMillis() - start));
    }
}
